<?php
namespace app\admin\model;

use app\common\model\Base;

/**
 * 用户组数据表名
 * Class AuthGroup
 * @package app\admin\model
 */
class AuthGroup extends Base
{
    protected $pk = 'id';
    protected $name = 'auth_group';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    /**
     * 获取列表
     */
    public function getRecord($where)
    {
        $lists = $this->where($where)->paginate(20);
        if (empty($lists)) {
            return [];
        }
        $names = AuthGroupName::getInstance()->column('*', 'id');
        $array = [];
        foreach ($lists as $item) {
            $item['auth_name'] = isset($names[$item['name_id']]) ? $names[$item['name_id']]['name'] : '';
            $array[$item['id']] = $item;
        }
        return $lists->toArray()['data'];

    }
}